//Prototype

Array.prototype.getPos = function (value) {
    for (let i = 0; i < this.length; i++) {
        if (this[i] === value) {
            return i;
        }
    }
    return -1;
};

Array.prototype.contains = function (value) {
    for (let i = 0; i < this.length; i++) {
        if (this[i] === value) {
            return true;
        }
    }
    return false;
};

Array.prototype.getObjectPos = function (key,value) {
    for (let i = 0; i < this.length; i++) {
        if(this[i] && this[i][key]){
            if (this[i][key] === value) {
                return i;
            }
        }
    }
    return -1;
};

Array.prototype.getObjectValue = function (key,value) {
    for (let i = 0; i < this.length; i++) {
        if(this[i] && this[i][key]){
            if (this[i][key] === value) {
                return this[i];
            }
        }
    }
    return null;
};

Array.prototype.getObjectContains = function (key,value) {
    for (let i = 0; i < this.length; i++) {
        if(this[i] && this[i][key]){
            if (this[i][key] === value) {
                return true;
            }
        }
    }
    return false;
};

Array.prototype.indexOf = function (val) {
    for (let i = 0; i < this.length; i++) {
        if (this[i] === val) return i;
    }
    return -1;
};

Array.prototype.remove = function (val) {
    let index = this.indexOf(val);
    if (index > -1) {
        this.splice(index, 1);
    }
    return this;
};

Array.prototype.clear = function () {
    this.length = 0;
};

String.prototype.append = function (str) {
    return String(this)+str;
};

String.prototype.trim = function()
{
    return String(this).replace(/^\s+|\s+$/g, '');
};

String.prototype.empty = function () {
    return !(this && this.length > 0);
};

String.prototype.replaceAll = function (FindText, RepText) {
    let regExp = new RegExp(FindText, "g");
    return this.replace(regExp, RepText);
};

String.prototype.endWith=function(str){
    if(str==null||str===""||this.length===0||str.length>this.length)
        return false;
    return this.substring(this.length - str.length) === str;
};

String.prototype.startWith=function(str){
    if(str==null||str===""||this.length===0||str.length>this.length)
        return false;
    return this.substr(0, str.length) === str;
};




